package com.bsj.power.common.def.entity.userOperateLog;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bsj.power.common.config.global.TokenUser;
import com.bsj.power.common.def.dto.user.UserAddDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author LiJiaXin
 * @version 1.0.0
 * @description UserOperateLog
 * @time 2024/10/16 15:45
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "tab_user_operate_log")
public class UserOperateLog {

    /**
     * 主键ID
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 操作类型 1新增 2修改 3删除
     */
    @TableField(value = "operate_type")
    private Integer operateType;

    /**
     * 操作模块 1用户 2角色
     */
    @TableField(value = "operate_module")
    private Integer operateModule;

    /**
     * IP
     */
    @TableField(value = "ip")
    private String ip;

    /**
     * 操作账号
     */
    @TableField(value = "user_name")
    private String userName;

    /**
     * 账号类型 0系统自带用户 1外部人员系统用户
     */
    @TableField(value = "user_type")
    private Integer userType;

    /**
     * 操作内容
     */
    @TableField(value = "content_operate")
    private String contentOperate;

    /**
     * 备注
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    public UserOperateLog(Integer operateType, Integer operateModule, String ip, TokenUser tokenUser) {
        this.operateType = operateType;
        this.operateModule = operateModule;
        this.ip = ip;
        this.userName = tokenUser.getUserName();
        this.userType = tokenUser.getUserType();
    }
}
